package me.xsomnus.shardingjdbcdemo2.controller;

import me.xsomnus.shardingjdbcdemo2.pojo.entity.Order;
import me.xsomnus.shardingjdbcdemo2.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author somnus_xiawenye
 * @since 2018/9/30 16:32
 */
@RestController
public class OrderController {

    @Autowired
    OrderService orderService;

    @PostMapping("/order")
    public boolean addOrder(@RequestBody Order order) {
        return orderService.save(order);
    }

    @GetMapping("/order/{orderId}")
    public Order order(@PathVariable Long orderId) {
        return orderService.getById(orderId);
    }
}
